package com.daocao.yfb.constant;

import com.daocao.yfb.Application;
import com.daocao.yfb.api.model.InitAppModel;
import com.daocao.yfb.api.model.UserInfoModel;
import com.daocao.yfb.util.PreferenceUtils;

/**
 * Created by xsooy-pc on 18-3-7.
 */

public class UserInfoGlobal {
    public static void saveInitData(InitAppModel.DataBean item) {
        PreferenceUtils.putString(Application.getInstance(), "is_login", item.is_logined);
    }

    public static void saveUserData(UserInfoModel.DatasBean item) {
        PreferenceUtils.putString(Application.getInstance(), "icon", item.icon);
        PreferenceUtils.putString(Application.getInstance(), "merchant_name", item.merchant_name);
        PreferenceUtils.putString(Application.getInstance(), "username", item.username);
        PreferenceUtils.putString(Application.getInstance(), "par_value", item.par_value);
        PreferenceUtils.putString(Application.getInstance(), "yunlian_url", item.yunlian_url);
        PreferenceUtils.putString(Application.getInstance(), "phone", item.phone);
    }

    public static boolean isLogin() {
        if (PreferenceUtils.getString(Application.getInstance(), "is_login", "0").equals("1")) {
            return true;
        } else {
            return false;
        }
    }

    public static void login() {
        PreferenceUtils.putString(Application.getInstance(), "is_login", "1");
    }

    public static void logout() {
        PreferenceUtils.putString(Application.getInstance(), "is_login", "");
    }
}
